﻿Imports System.Data.SqlClient

Public Class UserDAO
    Public Shared Function LayTaiKhoan(ByVal _userName As String, ByVal _passWord As String) As NguoiDungDTO

        Dim lstPara As List(Of SqlParameter) = New List(Of SqlParameter)
        Dim para As SqlParameter = New SqlParameter()
        para.ParameterName = "@UserName"
        para.SqlDbType = SqlDbType.NVarChar
        para.Value = _userName
        lstPara.Add(para)

        para = New SqlParameter()
        para.ParameterName = "@PassWord"
        para.SqlDbType = SqlDbType.NVarChar
        para.Value = _passWord
        lstPara.Add(para)

        Dim userDTO As NguoiDungDTO = New NguoiDungDTO()
        Dim dt As DataTable = New DataTable()
        dt = DataProvider.Executequery("usp_DangNhap", lstPara)
        If dt.Rows.Count > 0 Then
            userDTO.TenDangNhap = dt.Rows(0)("TenDangNhap").ToString()
            userDTO.Quyen = Integer.Parse(dt.Rows(0)("Quyen").ToString())
        End If
        Return userDTO
    End Function

    Public Function LayDanhSachBenhNhan() As DataTable
        Dim dt As DataTable = New DataTable()

        dt = DataProvider.Executequery("usp_LoadDachSachBenhNhan")

        Return dt
    End Function

    Public Shared Function Login(ByVal nguoidungDTO As NguoiDungDTO) As DataTable
        Dim dt As DataTable = New DataTable()
        dt = DataProvider.Executequery("usp_DangNhap")
        Return dt
    End Function
End Class
